//=============================================================================
/**
 *
 *	@file		museum_event.c
 *	@brief		ポケスロン イベントレコード画面
 *	@author		hosaka genya
 *	@data		2008.08.23
 *
 */
//=============================================================================
#include "common.h"
#include "gflib/touchpanel.h"
#include "gflib/strbuf_family.h"
#include "system/procsys.h"
#include "system/arc_util.h"
#include "system/arc_tool.h"
#include "system/brightness.h"
#include "system/bmp_list.h"
#include "system/bmp_menu.h"
#include "system/window.h"
#include "system/pm_str.h"
#include "system/msgdata.h"
#include "system/wordset.h"
#include "system/fontproc.h"
#include "system/snd_tool.h"
#include "system/clact_util.h"
#include "system/clact_tool.h"
#include "system/render_oam.h"
#include "system/gra_tool.h"
#include "system/palanm.h"
#include "system/wipe.h"
#include "poketool/poke_tool.h"
#include "poketool/pokeicon.h"
#include "msgdata/msg.naix"
#include "msgdata/msg_pokethlon_museum.h"

#include "application/app_tool.h"
#include "application/museum.h"

#include "museum_util.h"
#include "museum_obj.h"
#include "museum_bg.h"

#include "system/pm_overlay.h"

#include "pkth_museum.naix"
#include "obj_trophy_NANR_LBLDEFS.h"

FS_EXTERN_OVERLAY(pkthln_common);

//=============================================================================
/**
 *								定数定義
 */
//=============================================================================

//--------------------------------------------------------------
///	BG関係のENUM
//==============================================================
enum
{
	BMPWIN_M_CGX = 1,
	BMPWIN_S_CGX = 1,

	BG_USE_NUM = 6,
	FRM_M_BASE	= GF_BGL_FRAME0_M,
	FRM_M_TEXT	= GF_BGL_FRAME1_M,
	FRM_M_ICON	= GF_BGL_FRAME2_M,
	FRM_S_BASE	= GF_BGL_FRAME0_S,
	FRM_S_TEXT	= GF_BGL_FRAME1_S,
	FRM_S_ICON	= GF_BGL_FRAME2_S,

	BG_EVICON_DEF_X = 1, BG_EVICON_DEF_Y = 6,
	BG_EVICON_DIFF_X = 6, BG_EVICON_DIFF_Y = 8,

	//-- カーソル座標
	OBJPOS_CUR_DEF_X	= 4*8,
	OBJPOS_CUR_DEF_Y	= 9*8,
	OBJPOS_CUR_DIFF_X	= 6*8,
	OBJPOS_CUR_DIFF_Y	= 8*8,
	OBJPOS_S_1ST_X		= 29*8,
	OBJPOS_S_1ST_Y		= 6*8,
};

// -- 使用するBGテーブル
static const u8 c_BG_UseList[ BG_USE_NUM ] = {
	GF_BGL_FRAME0_M, GF_BGL_FRAME1_M, GF_BGL_FRAME2_M,
	GF_BGL_FRAME0_S, GF_BGL_FRAME1_S, GF_BGL_FRAME2_S,
};


//--------------------------------------------------------------
///	OBJ_ID
//==============================================================
enum {
	OBJ_POKEICON_ROW	= 3,
	OBJ_POKEICON_LINE	= 5,
	OBJ_POKEICON_MAX	= OBJ_POKEICON_ROW * OBJ_POKEICON_LINE,

	BG_EVICON_ROW		= 5,
	BG_EVICON_LINE		= 2,
	BG_EVICON_MAX		= BG_EVICON_ROW * BG_EVICON_LINE,

	BTN_IDX_CHG		= -1,
	BTN_IDX_RETURN	= BG_EVICON_MAX,

	// -- Main LCD --
	OBJ_ID_CURSOR = 0,
	OBJ_ID_S_1ST,
	OBJ_ID_COMMON_MAX,
	OBJ_ID_EVICON_TROPHY_HEAD	= OBJ_ID_COMMON_MAX,
	OBJ_ID_EVICON_RIBBON_HEAD	= OBJ_ID_EVICON_TROPHY_HEAD	+ BG_EVICON_MAX,
	OBJ_ID_S_POKEICON_HEAD		= OBJ_ID_EVICON_RIBBON_HEAD	+ BG_EVICON_MAX,
	OBJ_ID_MAX					= OBJ_ID_S_POKEICON_HEAD	+ OBJ_POKEICON_MAX,
};

//--------------------------------------------------------------
///	OBJ用：リソースID
//==============================================================
enum {
	CHR_ID_M_TROPHY = 0,
	CHR_ID_S_EVENT,
	CHR_ID_S_POKEICON_HEAD,
	CHR_ID_MAX = CHR_ID_S_POKEICON_HEAD + OBJ_POKEICON_MAX,
};

enum {
	PAL_ID_M_TROPHY = 0,
	PAL_ID_S_EVENT,
	PAL_ID_S_POKEICON,
	PAL_ID_MAX,
};

enum {
	CEL_ID_TROPHY = 0,
	CEL_ID_S_EVENT,
	CEL_ID_POKEICON,
	CEL_ID_MAX,
};

enum {
	ANM_ID_TROPHY = 0,
	ANM_ID_S_EVENT,
	ANM_ID_POKEICON,
	ANM_ID_MAX,
};

//--------------------------------------------------------------
///	BMPWIN用IDX
//==============================================================
enum
{
	// Main LCD
	BMPWIN_ID_MODE_CAP = 0,
	BMPWIN_ID_MDOE_BTN,
	BMPWIN_ID_EVNAME,
	BMPWIN_ID_JOIN,
	BMPWIN_ID_RETURN,
	// Sub LCD
	BMPWIN_ID_S_EVNAME_R,
	BMPWIN_ID_S_EVTRP,
#ifdef PRINT_RANK_FONT
	BMPWIN_ID_S_RNK01,
	BMPWIN_ID_S_RNK02,
	BMPWIN_ID_S_RNK03,
	BMPWIN_ID_S_RNK04,
	BMPWIN_ID_S_RNK05,
#endif
	BMPWIN_ID_S_TIME01,
	BMPWIN_ID_S_TIME02,
	BMPWIN_ID_S_TIME03,
	BMPWIN_ID_S_TIME04,
	BMPWIN_ID_S_TIME05,
	BMPWIN_ID_S_COMMTR01,
	BMPWIN_ID_S_COMMTR02,
	BMPWIN_ID_S_COMMTR03,
	BMPWIN_ID_S_COMMTR04,
	BMPWIN_ID_S_COMMTR05,
	BMPWIN_ID_S_POINT,
	BMPWIN_ID_S_POINT_CAP,
	BMPWIN_ID_MAX,
};


//=============================================================================
/**
 *								構造体定義
 */
//=============================================================================

//--------------------------------------------------------------
///	モジュール上で参照しか行わないデータ
//==============================================================
typedef struct {
	PKTH_MUSEUM_EV_PARAM*	p_param;
	PKTH_EVT_DATA			ev_alone[ PKTHLN_EVT_MAX ];
	STRBUF*					trname;
} CONST_DATA;

//--------------------------------------------------------------
///	メインワーク
//==============================================================
typedef struct {
	const CONST_DATA*	wk_con;
	GF_BGL_INI*			p_bgl;
	ARCHANDLE*			p_arc_pkth_museum;
	HEAPID				heapID;

	MUSEUM_MSG_WORK*	wk_msg;
	MUSEUM_OBJ_WORK*	wk_obj;
	CATS_ACT_PTR		cap[ OBJ_ID_MAX ];

	s8					ev_idx;
	s8					cur_row_old; // 前回のカーソルのX座標
	u8					padding[2];

	BOOL				b_comm;
	BOOL				b_comm_flash;
	BOOL				b_gph_flash;
	BOOL				b_1st_dummy[ PKTHLN_EVT_MAX ]; ///< 一位がダミーデータか判定フラグ
} MUSEUM_EV_WORK;

//=============================================================================
/**
 *								データテーブル
 */
//=============================================================================

//--------------------------------
// BMPWIN 関係
//--------------------------------
#define BMP_STR_H ( 2 )
#define BMP_STRING_LONG_H ( 6 )

//-- main
#define BMP_MODE_CAP_W	( 20 )
#define BMP_MODE_BTN_W	( 6 )
#define BMP_EVNAME_W	( 24 )
#define BMP_JOIN_W		( 24 )
#define BMP_RETURN_W	( 6 )

//-- main cgx
#define BMP_MODE_CAP_CGX	( BMPWIN_M_CGX )
#define BMP_MODE_BTN_CGX	( BMP_MODE_CAP_CGX	+ BMP_MODE_CAP_W	* BMP_STR_H )
#define BMP_EVNAME_CGX		( BMP_MODE_BTN_CGX	+ BMP_MODE_BTN_W	* BMP_STR_H )
#define BMP_JOIN_CGX		( BMP_EVNAME_CGX	+ BMP_EVNAME_W		* BMP_STR_H )
#define BMP_RETURN_CGX		( BMP_JOIN_CGX		+ BMP_JOIN_W		* BMP_STR_H )

//-- sub
#define BMP_S_EVNAME_R_W	( 26 )
#define BMP_S_EVTRP_W		( 22 )
#define BMP_S_RNK01_W		( 4 )
#define BMP_S_RNK02_W		( 4 )
#define BMP_S_RNK03_W		( 4 )
#define BMP_S_RNK04_W		( 4 )
#define BMP_S_RNK05_W		( 4 )
#define BMP_S_TIME01_W		( 11 )
#define BMP_S_TIME02_W		( 11 )
#define BMP_S_TIME03_W		( 11 )
#define BMP_S_TIME04_W		( 11 )
#define BMP_S_TIME05_W		( 11 )
#define BMP_S_COMMTR_W		( 11 )
#define BMP_S_POINT_W		( 3 )
#define BMP_S_POINT_CAP_W	( 6 )

//-- sub cgx
#define BMP_S_EVNAME_R_CGX	( BMPWIN_S_CGX )
#define BMP_S_EVTRP_CGX	( BMP_S_EVNAME_R_CGX +	BMP_STR_H * BMP_S_EVNAME_R_W )
#define BMP_S_RNK01_CGX	( BMP_S_EVTRP_CGX +		BMP_STR_H * BMP_S_EVTRP_W )
#define BMP_S_RNK02_CGX	( BMP_S_RNK01_CGX +		BMP_STR_H * BMP_S_RNK01_W )
#define BMP_S_RNK03_CGX	( BMP_S_RNK02_CGX +		BMP_STR_H * BMP_S_RNK02_W )
#define BMP_S_RNK04_CGX	( BMP_S_RNK03_CGX +		BMP_STR_H * BMP_S_RNK03_W )
#define BMP_S_RNK05_CGX	( BMP_S_RNK04_CGX +		BMP_STR_H * BMP_S_RNK04_W )
#define BMP_S_TIME01_CGX	( BMP_S_RNK05_CGX +		BMP_STR_H * BMP_S_RNK05_W )
#define BMP_S_TIME02_CGX	( BMP_S_TIME01_CGX +	BMP_STR_H * BMP_S_TIME01_W )
#define BMP_S_TIME03_CGX	( BMP_S_TIME02_CGX +	BMP_STR_H * BMP_S_TIME02_W )
#define BMP_S_TIME04_CGX	( BMP_S_TIME03_CGX +	BMP_STR_H * BMP_S_TIME03_W )
#define BMP_S_TIME05_CGX	( BMP_S_TIME04_CGX +	BMP_STR_H * BMP_S_TIME04_W )
#define BMP_S_COMMTR01_CGX	( BMP_S_TIME05_CGX +	BMP_STR_H * BMP_S_TIME05_W )
#define BMP_S_COMMTR02_CGX	( BMP_S_COMMTR01_CGX +	BMP_STR_H * BMP_S_COMMTR_W )
#define BMP_S_COMMTR03_CGX	( BMP_S_COMMTR02_CGX +	BMP_STR_H * BMP_S_COMMTR_W )
#define BMP_S_COMMTR04_CGX	( BMP_S_COMMTR03_CGX +	BMP_STR_H * BMP_S_COMMTR_W )
#define BMP_S_COMMTR05_CGX	( BMP_S_COMMTR04_CGX +	BMP_STR_H * BMP_S_COMMTR_W )
#define BMP_S_POINT_CGX		( BMP_S_COMMTR05_CGX +	BMP_STR_H * BMP_S_COMMTR_W )
#define BMP_S_POINT_CAP_CGX	( BMP_S_POINT_CGX  +	BMP_STR_H * BMP_S_POINT_W )

//--------------------------------------------------------------
///	つうしんとのBMPWIN座標切替用
//==============================================================
enum
{
	BW_TIME_POSY_1 = 4,
	BW_TIME_POSY_2 = 9,
	BW_TIME_POSY_3 = 13,
	BW_TIME_POSY_4 = 17,
	BW_TIME_POSY_5 = 21,

	BW_CTIME_POSY_DEF = 6,
	BW_CTIME_POSY_DIFF = 4,

	BW_CTIME_POSY_1 = BW_CTIME_POSY_DEF,
	BW_CTIME_POSY_2 = BW_CTIME_POSY_DEF + BW_CTIME_POSY_DIFF,
	BW_CTIME_POSY_3 = BW_CTIME_POSY_DEF + BW_CTIME_POSY_DIFF * 2,
	BW_CTIME_POSY_4 = BW_CTIME_POSY_DEF + BW_CTIME_POSY_DIFF * 3,
	BW_CTIME_POSY_5 = BW_CTIME_POSY_DEF + BW_CTIME_POSY_DIFF * 4,
};

//--------------------------------------------------------------
///	アクセス用データテーブル
//==============================================================
static const u8 c_BWTimePosY[][2] =
{
	{ BW_TIME_POSY_1, BW_CTIME_POSY_1 },
	{ BW_TIME_POSY_2, BW_CTIME_POSY_2 },
	{ BW_TIME_POSY_3, BW_CTIME_POSY_3 },
	{ BW_TIME_POSY_4, BW_CTIME_POSY_4 },
	{ BW_TIME_POSY_5, BW_CTIME_POSY_5 },
};

//--------------------------------------------------------------
///	BMPWIN用 データテーブル
//==============================================================
static const BMPWIN_DAT c_BmpWinList[ BMPWIN_ID_MAX ] =
{
	// -- main --
	{ FRM_M_TEXT, 0,	1,	BMP_MODE_CAP_W,		BMP_STR_H, FONT_TALK_PAL, BMP_MODE_CAP_CGX, },	// BMPWIN_ID_MODE_CAP
	{ FRM_M_TEXT, 25,	1,	BMP_MODE_BTN_W,		BMP_STR_H, FONT_TALK_PAL, BMP_MODE_BTN_CGX, },	// BMPWIN_ID_MDOE_BTN
	{ FRM_M_TEXT, 0,	20,	BMP_EVNAME_W,		BMP_STR_H, FONT_TALK_PAL, BMP_EVNAME_CGX, },		// BMPWIN_ID_EVNAME
	{ FRM_M_TEXT, 0,	22,	BMP_JOIN_W,			BMP_STR_H, FONT_TALK_PAL, BMP_JOIN_CGX, },		// BMPWIN_ID_JOIN
	{ FRM_M_TEXT, 26,	21,	BMP_RETURN_W,		BMP_STR_H, FONT_TALK_PAL, BMP_RETURN_CGX, },		// BMPWIN_ID_RETURN
	// -- sub --
	{ FRM_S_TEXT, 1,	0,	BMP_S_EVNAME_R_W,	BMP_STR_H, FONT_TALK_PAL, BMP_S_EVNAME_R_CGX, },	// BMPWIN_ID_S_EVNAME_R
	{ FRM_S_TEXT, 1,	2,	BMP_S_EVTRP_W,		BMP_STR_H, FONT_TALK_PAL, BMP_S_EVTRP_CGX, },	// BMPWIN_ID_S_EVTRP
#ifdef PRINT_RANK_FONT
	{ FRM_S_TEXT, 3,	6,	BMP_S_RNK01_W,		BMP_STR_H, FONT_TALK_PAL, BMP_S_RNK01_CGX, },	// BMPWIN_ID_S_RNK01
	{ FRM_S_TEXT, 4,	10,	BMP_S_RNK02_W,		BMP_STR_H, FONT_TALK_PAL, BMP_S_RNK02_CGX, },	// BMPWIN_ID_S_RNK02
	{ FRM_S_TEXT, 5,	14,	BMP_S_RNK03_W,		BMP_STR_H, FONT_TALK_PAL, BMP_S_RNK03_CGX, },	// BMPWIN_ID_S_RNK03
	{ FRM_S_TEXT, 6,	18,	BMP_S_RNK04_W,		BMP_STR_H, FONT_TALK_PAL, BMP_S_RNK04_CGX, },	// BMPWIN_ID_S_RNK04
	{ FRM_S_TEXT, 7,	22,	BMP_S_RNK05_W,		BMP_STR_H, FONT_TALK_PAL, BMP_S_RNK05_CGX, },	// BMPWIN_ID_S_RNK05
#endif
	{ FRM_S_TEXT, 16,	BW_TIME_POSY_1,			BMP_S_TIME01_W, BMP_STR_H, FONT_TALK_PAL, BMP_S_TIME01_CGX, },	// BMPWIN_ID_S_TIME01
	{ FRM_S_TEXT, 17,	BW_TIME_POSY_2,			BMP_S_TIME02_W,	BMP_STR_H, FONT_TALK_PAL, BMP_S_TIME02_CGX, },	// BMPWIN_ID_S_TIME02
	{ FRM_S_TEXT, 18,	BW_TIME_POSY_3,			BMP_S_TIME03_W,	BMP_STR_H, FONT_TALK_PAL, BMP_S_TIME03_CGX, },	// BMPWIN_ID_S_TIME03
	{ FRM_S_TEXT, 19,	BW_TIME_POSY_4,			BMP_S_TIME04_W,	BMP_STR_H, FONT_TALK_PAL, BMP_S_TIME04_CGX, },	// BMPWIN_ID_S_TIME04
	{ FRM_S_TEXT, 20,	BW_TIME_POSY_5,			BMP_S_TIME05_W,	BMP_STR_H, FONT_TALK_PAL, BMP_S_TIME05_CGX, },	// BMPWIN_ID_S_TIME05
	{ FRM_S_TEXT, 16,	BW_CTIME_POSY_1-2,		BMP_S_COMMTR_W,	BMP_STR_H, FONT_TALK_PAL, BMP_S_COMMTR01_CGX, },	// BMPWIN_ID_S_COMMTR01
	{ FRM_S_TEXT, 17,	BW_CTIME_POSY_2-2,		BMP_S_COMMTR_W,	BMP_STR_H, FONT_TALK_PAL, BMP_S_COMMTR02_CGX, },	// BMPWIN_ID_S_COMMTR02
	{ FRM_S_TEXT, 18,	BW_CTIME_POSY_3-2,		BMP_S_COMMTR_W,	BMP_STR_H, FONT_TALK_PAL, BMP_S_COMMTR03_CGX, },	// BMPWIN_ID_S_COMMTR03
	{ FRM_S_TEXT, 19,	BW_CTIME_POSY_4-2,		BMP_S_COMMTR_W,	BMP_STR_H, FONT_TALK_PAL, BMP_S_COMMTR04_CGX, },	// BMPWIN_ID_S_COMMTR04
	{ FRM_S_TEXT, 20,	BW_CTIME_POSY_5-2,		BMP_S_COMMTR_W,	BMP_STR_H, FONT_TALK_PAL, BMP_S_COMMTR05_CGX, },	// BMPWIN_ID_S_COMMTR05
	{ FRM_S_TEXT, 17,	6,	BMP_S_POINT_W,		BMP_STR_H, FONT_TALK_PAL, BMP_S_POINT_CGX, },		// BMPWIN_ID_S_POINT
	{ FRM_S_TEXT, 20,	6,	BMP_S_POINT_CAP_W,	BMP_STR_H, FONT_TALK_PAL, BMP_S_POINT_CAP_CGX, },	// BMPWIN_ID_S_POINT_CAP
};

//=============================================================================
/**
 *							プロトタイプ宣言
 */
//=============================================================================
// -- prottype --
PROC_RESULT MuseumEventProc_Init( PROC *proc, int *seq);
PROC_RESULT MuseumEventProc_End( PROC *proc,int *seq);
PROC_RESULT MuseumEventProc_Main( PROC *proc,int *seq);
static BOOL check_record_flag( MUSEUM_EV_WORK* wk, s8 ev_idx );
static BOOL check_trophy_flag( MUSEUM_EV_WORK* wk, s8 ev_idx, BOOL b_clear );
static BOOL check_data_none( MUSEUM_EV_WORK* wk, u8 rnk_idx );
static void COMMON_VBlank( void* work );
static void BG_Init( MUSEUM_EV_WORK* wk );
static void BG_LoadRes( MUSEUM_EV_WORK* wk );
static void BG_LoadEvIcon( MUSEUM_EV_WORK* wk, u8 icon_idx, s16 pos_x, s16 pos_y, BOOL b_clear, BOOL b_sub );
static void BG_Release( MUSEUM_EV_WORK* wk );
static void BG_Flash( MUSEUM_EV_WORK* wk );
static void COMM_Init( MUSEUM_EV_WORK* wk );
static void COMM_Flash( MUSEUM_EV_WORK* wk );
static void PRINT_StaticMessage( MUSEUM_EV_WORK* wk );
static void PRINT_Record( MUSEUM_EV_WORK* wk, u16 scr, u32 win_idx, u32 msg_idx );
static void PRINT_Mode( MUSEUM_EV_WORK* wk );
static void PRINT_CursorMessage( MUSEUM_EV_WORK* wk );
static void OBJ_Init( MUSEUM_EV_WORK* wk );
static void OBJ_Flash( MUSEUM_EV_WORK* wk );
static void OBJ_LoadRes( MUSEUM_EV_WORK* wk );
static void OBJ_AddCommon( MUSEUM_EV_WORK * wk );
static void OBJ_AddEvIconOption( MUSEUM_EV_WORK* wk );
static void OBJ_AddPokeIcon( MUSEUM_EV_WORK* wk );
static void OBJ_PokeIconFlash( MUSEUM_EV_WORK* wk );
static void OBJ_PokeIconEnable( MUSEUM_EV_WORK* wk, BOOL b_enable );
static void BMPWIN_ClearCommTrainerName( MUSEUM_EV_WORK* wk );
static void EVICON_Flash( MUSEUM_EV_WORK* wk );
static BOOL CURSOR_Proc( MUSEUM_EV_WORK* wk );
static void CONST_DATA_Create( MUSEUM_EV_WORK*wk, PKTH_MUSEUM_EV_PARAM* p_param );
static void CONST_DATA_Release( const CONST_DATA* wk );
static BOOL CONST_DATA_GetMuseumOpenFlag( const CONST_DATA* wk );
static const PKTH_EVT_DATA* get_evt_data( const CONST_DATA* wk, u8 ev_idx, BOOL b_comm );
static void CONST_DATA_GetMonsDataPtr( const CONST_DATA* wk, MONS_DATA* p_dst, int ev_idx, int rank_idx, int pk_idx, BOOL b_comm );
static u16 CONST_DATA_GetEventRecord( const CONST_DATA* wk, s8 ev_idx, u8 rnk_idx, BOOL b_comm );
static u32 CONST_DATA_GetJoinCount( const CONST_DATA* wk, u8 ev_idx, BOOL b_comm );
static const MYSTATUS* CONST_DATA_GetMyStatus( const CONST_DATA* wk );
static u16 CONST_DATA_GetEventPoint( const CONST_DATA* wk, u8 ev_idx );
static STRBUF* CONST_DATA_GetCommTrainerName( const CONST_DATA* wk, u8 ev_idx, u8 rnk_idx );

//-----------------------------------------------------------------------------
/**
 *	@brief	競技ベストスコアを表示
 *
 *	@param	const CONST_DATA* wk
 *	@param	ev_idx
 *
 *	@retval
 */
//-----------------------------------------------------------------------------
static u16 CONST_DATA_GetEventPoint( const CONST_DATA* wk, u8 ev_idx )
{
	GF_ASSERT( wk );
	GF_ASSERT( ev_idx < PKTHLN_EVT_MAX );

	return wk->p_param->p_best_score_dat[ ev_idx ];

}

//=============================================================================
/**
 *								外部公開関数
 */
//=============================================================================

//==============================================================================
/**
 *	@brief	プロセス初期化
 *	@param	proc	プロセスデータ
 *	@param	seq		シーケンス
 *
 *	@return	処理状況
 */
//==============================================================================
PROC_RESULT MuseumEventProc_Init( PROC *proc, int *seq)
{
	MUSEUM_EV_WORK *wk = NULL;
	PKTH_MUSEUM_EV_PARAM * p_param;

	Overlay_Load( FS_OVERLAY_ID(pkthln_common), OVERLAY_LOAD_NOT_SYNCHRONIZE );

	p_param = (PKTH_MUSEUM_EV_PARAM*)PROC_GetParentWork( proc );

	GF_ASSERT( p_param );

	//ヒープ作成
	sys_CreateHeap( HEAPID_BASE_APP, HEAPID_PKTH_MUSEUM, 0x30000 );

	wk = PROC_AllocWork( proc, sizeof(MUSEUM_EV_WORK), HEAPID_PKTH_MUSEUM );
	MI_CpuClear8( wk, sizeof(MUSEUM_EV_WORK) );

	// パラメータ設定
	wk->heapID = HEAPID_PKTH_MUSEUM;

	// コンストデータ生成
	CONST_DATA_Create( wk, p_param );

	// 汎用初期化処理
	MUSEUM_COMMON_Init();

	// BG初期化
	BG_Init( wk );
	BG_LoadRes( wk );
	wk->wk_msg = MUSEUM_BMPWIN_Create( wk->heapID, wk->p_bgl, BMPWIN_ID_MAX, c_BmpWinList, NARC_msg_pokethlon_museum_dat );

	PRINT_StaticMessage( wk );
	BG_Flash( wk );

	// OBJ初期化
	OBJ_Init( wk );

	COMM_Init( wk );

	WIPE_ResetWndMask( WIPE_DISP_MAIN );
	WIPE_ResetWndMask( WIPE_DISP_SUB );

	sys_VBlankFuncChange( COMMON_VBlank, wk );

	return PROC_RES_FINISH;

}

//==============================================================================
/**
 *	@brief	プロセス終了
 *	@param	proc	プロセスデータ
 *	@param	seq		シーケンス
 *
 *	@return	処理状況
 */
//==============================================================================
PROC_RESULT MuseumEventProc_End( PROC *proc,int *seq)
{
	MUSEUM_EV_WORK* wk = PROC_GetWork( proc );

	//コンストデータ開放
	CONST_DATA_Release( wk->wk_con );

	// -- OBJ
	MUSEUM_OBJ_Delete( wk->wk_obj, wk->cap, OBJ_ID_MAX );

	// -- BG
	MUSEUM_BMPWIN_Delete( wk->wk_msg, BMPWIN_ID_MAX );
	BG_Release( wk );

	// -- COMMON
	MUSEUM_COMMON_Release();

	//ワークエリア解放
	PROC_FreeWork( proc );

	sys_DeleteHeap( HEAPID_PKTH_MUSEUM );

	Overlay_UnloadID( FS_OVERLAY_ID(pkthln_common) );

	return PROC_RES_FINISH;

}

//==============================================================================
/**
 *	@brief	プロセスメイン
 *	@param	proc	プロセスデータ
 *	@param	seq		シーケンス
 *
 *	@return	処理状況
 */
//==============================================================================
PROC_RESULT MuseumEventProc_Main( PROC *proc,int *seq)
{
	enum
	{
		MAIN_SEQ_INIT = 0,
		MAIN_SEQ_FADE_IN,
		MAIN_SEQ_MAIN,
		MAIN_SEQ_FADE_OUT,
		MAIN_SEQ_END,
	};

	MUSEUM_EV_WORK* wk = PROC_GetWork(proc);

	switch( *seq )
	{
		case MAIN_SEQ_INIT :
			WIPE_SYS_Start( WIPE_PATTERN_WMS, WIPE_TYPE_FADEIN, WIPE_TYPE_FADEIN,
							0x0000, COMM_BRIGHTNESS_SYNC, 1, wk->heapID );
			(*seq) = MAIN_SEQ_FADE_IN;
			break;

		case MAIN_SEQ_FADE_IN :
			if( WIPE_SYS_EndCheck() )
			{
				(*seq) = MAIN_SEQ_MAIN;
			}
			break;

		case MAIN_SEQ_MAIN :
			//-- 表示更新（つうしんに関連する項目
			if( wk->b_comm_flash )
			{
				HOSAKA_PRINT( "call comm flash \n" );
				wk->b_comm ^= 1;
				COMM_Flash( wk );
			}

			//-- 表示更新
			if( wk->b_gph_flash )
			{
				HOSAKA_PRINT( "call obj flash \n" );

				BG_Flash( wk );
				OBJ_Flash( wk );
				wk->b_gph_flash = FALSE;
			}

			//-- カーソル処理 + 終了判定
			if( MUSEUM_UTIL_CheckExit() || CURSOR_Proc( wk ) )
			{
				Snd_SePlay( SEQ_SE_DP_SELECT );

				WIPE_SYS_Start( WIPE_PATTERN_WMS, WIPE_TYPE_FADEOUT, WIPE_TYPE_FADEOUT,
								0x0000, COMM_BRIGHTNESS_SYNC, 1, wk->heapID );
				(*seq) = MAIN_SEQ_FADE_OUT;
			}

			break;

		case MAIN_SEQ_FADE_OUT :
			if( WIPE_SYS_EndCheck() )
			{
				(*seq) = MAIN_SEQ_END;
			}
			break;

		case MAIN_SEQ_END :
			return PROC_RES_FINISH;

		default : GF_ASSERT( !"seq error!" );
	}

	MUSEUM_OBJ_Draw( wk->wk_obj );

	return PROC_RES_CONTINUE;
}

//=============================================================================
/**
 *								static関数
 */
//=============================================================================

//-----------------------------------------------------------------------------
/**
 *	@brief レコードの値が目的の値を超えているかチェック
 *
 *	@param	MUSEUM_EV_WORK* wk
 *	@param	ev_idx
 */
//-----------------------------------------------------------------------------
static BOOL check_record_flag( MUSEUM_EV_WORK* wk, s8 ev_idx )
{
	u16 rec = CONST_DATA_GetEventRecord( wk->wk_con, ev_idx, 0, wk->b_comm );	///< 一位のレコード

	return MUSEUM_UTIL_CheckEventRecordFlagTai( ev_idx, CONST_DATA_GetMuseumOpenFlag( wk->wk_con ), rec );
}

//-----------------------------------------------------------------------------
/**
 *	@brief	トロフィー表示判定
 *
 *	@param	MUSEUM_EV_WORK* wk
 *	@param	ev_idx
 *	@param	b_clear		TRUE:クリア後の条件
 */
//-----------------------------------------------------------------------------
static BOOL check_trophy_flag( MUSEUM_EV_WORK* wk, s8 ev_idx, BOOL b_clear )
{
	u16 rec = CONST_DATA_GetEventRecord( wk->wk_con, ev_idx, 0, FALSE );	///< 一位のレコード

	// つうしんでは必ず非表示
	if( wk->b_comm ) {
		return FALSE;
	} else {
		return MUSEUM_UTIL_CheckEventRecordFlagTai( ev_idx, b_clear, rec );
	}
}

//-----------------------------------------------------------------------------
/**
 *	@brief	データがないか判定
 *
 *	@param	MUSEUM_EV_WORK* wk
 *	@param	rnk_idx
 *
 *	@retval	TRUE:データがない
 */
//-----------------------------------------------------------------------------
static BOOL check_data_none( MUSEUM_EV_WORK* wk, u8 rnk_idx )
{
	u16 scr = CONST_DATA_GetEventRecord( wk->wk_con, wk->ev_idx, rnk_idx, wk->b_comm );

	return( scr == REC_NO_DATA );
}

//-----------------------------------------------------------------------------
/**
 *	@brief	VBlank処理
 *
 *	@param	* work
 *
 *	@retval	none
 */
//-----------------------------------------------------------------------------
static void COMMON_VBlank( void* work )
{
	MUSEUM_EV_WORK* wk = work;

	CATS_RenderOamTrans();
	GF_BGL_VBlankFunc( wk->p_bgl );
	OS_SetIrqCheckFlag( OS_IE_V_BLANK );
}

//-----------------------------------------------------------------------------
/**
 *	@brief	BG 初期化
 *
 *	@param	MUSEUM_EV_WORK* wk
 *
 *	@retval
 */
//-----------------------------------------------------------------------------
static void BG_Init( MUSEUM_EV_WORK* wk )
{
	wk->p_bgl = GF_BGL_BglIniAlloc( wk->heapID );

	{	//BG SYSTEM
		GF_BGL_SYS_HEADER BGsys_data = {
			GX_DISPMODE_GRAPHICS,GX_BGMODE_0,GX_BGMODE_0,GX_BG0_AS_2D
		};
		GF_BGL_InitBG(&BGsys_data);
	}

	{
		int i;
		GF_BGL_BGCNT_HEADER TextBgCntDat[ BG_USE_NUM ] = {
			// -- MAIN --
			{	// FRM_M_BASE BG0
				0,0,0x800,0,GF_BGL_SCRSIZ_256x256,GX_BG_COLORMODE_16,
				GX_BG_SCRBASE_0xe000,GX_BG_CHARBASE_0x00000,GX_BG_EXTPLTT_01,
				3,0,0,FALSE
			},
			{	//FRM_M_TEXT BG1
				0,0,0x800,0,GF_BGL_SCRSIZ_256x256,GX_BG_COLORMODE_16,
				GX_BG_SCRBASE_0xf800,GX_BG_CHARBASE_0x04000,GX_BG_EXTPLTT_01,
				0,0,0,FALSE
			},
			{	//FRM_M_ICON BG2
				0,0,0x800,0,GF_BGL_SCRSIZ_256x256,GX_BG_COLORMODE_16,
				GX_BG_SCRBASE_0xf000,GX_BG_CHARBASE_0x08000,GX_BG_EXTPLTT_01,
				0,0,0,FALSE
			},
			// -- SUB --
			{	// FRM_S_BASE BG0
				0,0,0x800,0,GF_BGL_SCRSIZ_256x256,GX_BG_COLORMODE_16,
				GX_BG_SCRBASE_0x0000,GX_BG_CHARBASE_0x04000,GX_BG_EXTPLTT_01,
				3,0,0,FALSE
			},
			{	// FRM_S_TEXT BG1
				0,0,0x800,0,GF_BGL_SCRSIZ_256x256,GX_BG_COLORMODE_16,
				GX_BG_SCRBASE_0x0800,GX_BG_CHARBASE_0x08000,GX_BG_EXTPLTT_01,
				0,0,0,FALSE
			},
			{	// FRM_S_ICON BG2
				0,0,0x800,0,GF_BGL_SCRSIZ_256x256,GX_BG_COLORMODE_16,
				GX_BG_SCRBASE_0x1000,GX_BG_CHARBASE_0x0c000,GX_BG_EXTPLTT_01,
				0,0,0,FALSE
			},
		};

		for( i=0; i<BG_USE_NUM; i++ )
		{
			GF_BGL_BGControlSet(wk->p_bgl, c_BG_UseList[i], &(TextBgCntDat[i]), GF_BGL_MODE_TEXT);
			GF_BGL_ScrClear(wk->p_bgl, c_BG_UseList[i]);
			GF_BGL_ClearCharSet(c_BG_UseList[i], 32, 0, wk->heapID);
		}
	}

	wk->p_arc_pkth_museum = ArchiveDataHandleOpen( ARC_PKTH_MUSEUM_GRA, wk->heapID );
}

//-----------------------------------------------------------------------------
/**
 *	@brief	BG リソースロード
 *
 *	@param	MUSEUM_EV_WORK* wk
 *
 *	@retval
 */
//-----------------------------------------------------------------------------
static void BG_LoadRes( MUSEUM_EV_WORK* wk )
{

	//----------------------------------------------------
	// Main LCD
	ArcUtil_HDL_PalSet( wk->p_arc_pkth_museum, NARC_pkth_museum_event_bg_NCLR, PALTYPE_MAIN_BG,
					0, 0, wk->heapID );

	// -- base --
	ArcUtil_HDL_BgCharSet( wk->p_arc_pkth_museum, NARC_pkth_museum_event_bg_lz_NCGR,
						wk->p_bgl, FRM_M_BASE, 0, 0, TRUE, wk->heapID );

	ArcUtil_HDL_ScrnSet( wk->p_arc_pkth_museum, NARC_pkth_museum_event_bg_lz_NSCR,
						wk->p_bgl, FRM_M_BASE, 0, 0, TRUE, wk->heapID );

	// -- ev_icon --
	ArcUtil_HDL_BgCharSet( wk->p_arc_pkth_museum, NARC_pkth_museum_event_bg_icon_lz_NCGR,
						wk->p_bgl, FRM_M_ICON , 1, 0, TRUE, wk->heapID );

	//----------------------------------------------------
	// Sub LCD
	ArcUtil_HDL_PalSet( wk->p_arc_pkth_museum, NARC_pkth_museum_event_bg_NCLR, PALTYPE_SUB_BG,
					0, 0, wk->heapID );

	// -- base --
	ArcUtil_HDL_BgCharSet( wk->p_arc_pkth_museum, NARC_pkth_museum_event_bg_lz_NCGR,
						wk->p_bgl, FRM_S_BASE, 0, 0, TRUE, wk->heapID );

	ArcUtil_HDL_ScrnSet( wk->p_arc_pkth_museum, NARC_pkth_museum_event_bg_sub_lz_NSCR,
						wk->p_bgl, FRM_S_BASE, 0, 0, TRUE, wk->heapID );

	// -- ev_icon --
	ArcUtil_HDL_BgCharSet( wk->p_arc_pkth_museum, NARC_pkth_museum_event_bg_icon_lz_NCGR,
						wk->p_bgl, FRM_S_ICON, 1, 0, TRUE, wk->heapID );

}

//-----------------------------------------------------------------------------
/**
 *	@brief	BG イベントアイコンを転送
 *
 *	@param	MUSEUM_EV_WORK* wk
 *	@param	icon_idx
 *	@param	pos_x
 *	@param	pos_y
 *	@param	b_clear	TRUE:枠が良い枠になる。
 *	@param	b_sub	TRUE:SUB画面に展開
 *
 *	@retval
 */
//-----------------------------------------------------------------------------
static void BG_LoadEvIcon( MUSEUM_EV_WORK* wk, u8 icon_idx, s16 pos_x, s16 pos_y, BOOL b_clear, BOOL b_sub )
{
	enum
	{
		SIZE_X = 6, SIZE_Y = 6,
		CLEAR_OFFSET = SIZE_X * SIZE_Y * BG_EVICON_MAX,	///< クリアー用のBGへのオフセット
	};

	int i, j;
	u8 bg_frm = b_sub ? FRM_S_ICON : FRM_M_ICON;

	for( i=0; i<SIZE_Y; i++ )
	{
		for( j=0; j<SIZE_X; j++ )
		{
			u16 write_chr = 1 + j + (icon_idx * SIZE_X ) +  (i * SIZE_X * BG_EVICON_MAX ) + ( b_clear * CLEAR_OFFSET );

			GF_BGL_ScrWrite( wk->p_bgl, bg_frm, &write_chr, pos_x + j, pos_y + i, 1, 1 );
		}
	}

	GF_BGL_LoadScreenReq( wk->p_bgl, bg_frm );
}

//-----------------------------------------------------------------------------
/**
 *	@brief	BG 開放
 *
 *	@param	MUSEUM_EV_WORK* wk
 *
 *	@retval	none
 */
//-----------------------------------------------------------------------------
static void BG_Release( MUSEUM_EV_WORK* wk )
{
	u8 i = 0;

	ArchiveDataHandleClose( wk->p_arc_pkth_museum );

	for( i=0; i<BG_USE_NUM; i++ )
	{
		GF_BGL_BGControlExit( wk->p_bgl, c_BG_UseList[i] );
	}

	sys_FreeMemoryEz( wk->p_bgl );
}

//-----------------------------------------------------------------------------
/**
 *	@brief	BG カーソル移動に依存する更新処理
 *
 *	@param	MUSEUM_EV_WORK* wk
 *
 *	@retval
 */
//-----------------------------------------------------------------------------
static void BG_Flash( MUSEUM_EV_WORK* wk )
{
	enum { BGICON_S_X = 26,	BGICON_S_Y = 0, };
	BOOL b_clear = (wk->b_comm) ? TRUE : !wk->b_1st_dummy[wk->ev_idx];

	PRINT_CursorMessage( wk );
	BG_LoadEvIcon( wk, wk->ev_idx, BGICON_S_X, BGICON_S_Y, b_clear, TRUE );
}

//-----------------------------------------------------------------------------
/**
 *	@brief	BGパレット切替(通信、非通信用)
 *
 *	@param	MUSEUM_EV_WORK* wk
 *
 *	@retval
 */
//-----------------------------------------------------------------------------
static void bg_chg_base_pltt( MUSEUM_EV_WORK* wk )
{
	u8 srcOfs = ( wk->b_comm ? 2 : 1 ) * 0x20;
	ArcUtil_HDL_PalSetEx( wk->p_arc_pkth_museum, NARC_pkth_museum_event_bg_NCLR, PALTYPE_MAIN_BG, srcOfs, 1*0x20, 1*0x20, wk->heapID );
	ArcUtil_HDL_PalSetEx( wk->p_arc_pkth_museum, NARC_pkth_museum_event_bg_NCLR, PALTYPE_SUB_BG, srcOfs, 1*0x20, 1*0x20, wk->heapID );
}

//-----------------------------------------------------------------------------
/**
 *	@brief	シングル/つうしん 依存物 初期化
 *
 *	@param	MUSEUM_EV_WORK* wk
 *
 *	@retval
 */
//-----------------------------------------------------------------------------
static void COMM_Init( MUSEUM_EV_WORK* wk )
{
	PRINT_Mode( wk );

	EVICON_Flash( wk );

}

//-----------------------------------------------------------------------------
/**
 *	@brief	シングル/つうしん　切替時の再描画処理
 *
 *	@param	MUSEUM_EV_WORK* wk
 *
 *	@retval
 */
//-----------------------------------------------------------------------------
static void COMM_Flash( MUSEUM_EV_WORK* wk )
{
	int i;

	PRINT_Mode( wk );

	EVICON_Flash( wk );

	// BGパレット切替
	bg_chg_base_pltt( wk );

	// レコード表示位置をずらす
	for( i=0; i<BEST_FIVE; i++ )
	{
		MUSEUM_BMPWIN_ClearAndTransReq( wk->wk_msg, BMPWIN_ID_S_TIME01 + i );
		MUSEUM_BMPWIN_OffVReq( wk->wk_msg, BMPWIN_ID_S_TIME01 + i ); // 移動するのでスクリーンもクリア
		MUSEUM_BMPWIN_SetPosY( wk->wk_msg, BMPWIN_ID_S_TIME01 + i, c_BWTimePosY[i][ wk->b_comm ] );
	}

	//========================================
	// 切り替えた瞬間は以下のものを消す
	//========================================
	OBJ_PokeIconEnable( wk, FALSE );
	GF_BGL_ScrClear( wk->p_bgl, FRM_S_ICON );
	CATS_ObjectEnableCap( wk->cap[ OBJ_ID_S_1ST ], FALSE );
	MUSEUM_BMPWIN_ClearAndTransReq( wk->wk_msg, BMPWIN_ID_JOIN );
	MUSEUM_BMPWIN_ClearAndTransReq( wk->wk_msg, BMPWIN_ID_S_EVTRP );
	MUSEUM_BMPWIN_ClearAndTransReq( wk->wk_msg, BMPWIN_ID_S_POINT );
	MUSEUM_BMPWIN_ClearAndTransReq( wk->wk_msg, BMPWIN_ID_S_POINT_CAP );

	// 通信トレーナー名を一端非表示
	BMPWIN_ClearCommTrainerName( wk );

	// 「きょうぎを　えらんで　ください」
	MUSEUM_BMPWIN_PrintAndSetOfs( wk->wk_msg, BMPWIN_ID_EVNAME,	msg_pkthRNK_evname_none, 1, 1 );

	// 「きょうぎの　きろく」
	MUSEUM_BMPWIN_PrintAndSetOfs( wk->wk_msg, BMPWIN_ID_S_EVNAME_R,	msg_pkthRNK_evnameR_none, 0, 1 );

	wk->b_comm_flash = FALSE;
}

//-----------------------------------------------------------------------------
/**
 *	@brief	BMPWIN 一度だけ描画すればいいもの
 *
 *	@param	MUSEUM_EV_WORK* wk
 *
 *	@retval
 */
//-----------------------------------------------------------------------------
static void PRINT_StaticMessage( MUSEUM_EV_WORK* wk )
{
	int i;

	MUSEUM_BMPWIN_PrintEx( wk->wk_msg, BMPWIN_ID_RETURN, msg_pkthRNK_return, FALSE, 0, FONT_TOUCH );

#ifdef PRINT_RANK_FONT
	// 順位フォントの表示
	for( i=0; i<BEST_FIVE; i++ )
	{
		MUSEUM_BMPWIN_Print( wk->wk_msg, BMPWIN_ID_S_RNK01 + i, msg_pkthRNK_evn_01 + i, FALSE );
	}
#endif
}

//-----------------------------------------------------------------------------
/**
 *	@brief	レコードを表示
 *
 *	@param	MUSEUM_EV_WORK* wk
 *	@param	score
 *	@param	win_idx
 *	@param	msg_idx
 *
 *	@retval
 */
//-----------------------------------------------------------------------------
static void PRINT_Record( MUSEUM_EV_WORK* wk, u16 score, u32 win_idx, u32 msg_idx )
{
	GF_ASSERT( score != REC_NO_DATA );

	if( wk->ev_idx == PKTHLN_EVT_DASH )
	{
		// ハードルは フレーム数を 秒表記(xx:x)
		u8 miri;
		u8 sec;

		//秒計算
		sec = score / 30;
		//秒以下
		miri = ( score % 30 ) * 10 / 30;

		MUSEUM_BMPWIN_RegistNum( wk->wk_msg, sec, 3, 0 );
		MUSEUM_BMPWIN_RegistNum( wk->wk_msg, miri, 1, 1 );
	}
	else if ( wk->ev_idx == PKTHLN_EVT_RUN )
	{
		// マラソン : 1024倍になっている
		MUSEUM_BMPWIN_RegistNum( wk->wk_msg, score/1024, 3, 0 );
		MUSEUM_BMPWIN_RegistNum( wk->wk_msg, (score%1024)*10/1024, 1, 1 );
	}
	else
	{
		MUSEUM_BMPWIN_RegistNum( wk->wk_msg, score, 3, 0 );
	}
	MUSEUM_BMPWIN_PrintRegStrWithPos( wk->wk_msg, win_idx, msg_pkthRNK_evunit_01 + wk->ev_idx, 0, 1 );
}

//-----------------------------------------------------------------------------
/**
 *	@brief	モード表記を描画
 *
 *	@param	MUSEUM_EV_WORK* wk
 *
 *	@retval
 */
//-----------------------------------------------------------------------------
static void PRINT_Mode( MUSEUM_EV_WORK* wk )
{
	static const tbl[][2] = {
		{ msg_pkthRNK_ev,		msg_pkthRNK_ev_t },
		{ msg_pkthRNK_evbutton,	msg_pkthRNK_evbutton_t },
	};

	MUSEUM_BMPWIN_PrintAndSetOfs( wk->wk_msg, BMPWIN_ID_MODE_CAP, tbl[0][ wk->b_comm ], 1, 0 );
	MUSEUM_BMPWIN_PrintEx( wk->wk_msg, BMPWIN_ID_MDOE_BTN, tbl[1][ wk->b_comm ], FALSE, 0, FONT_TOUCH );
}


//-----------------------------------------------------------------------------
/**
 *	@brief	BMPWIN カーソルが移動するたびに更新するもの
 *
 *	@param	MUSEUM_EV_WORK* wk
 *
 *	@retval
 */
//-----------------------------------------------------------------------------
static void PRINT_CursorMessage( MUSEUM_EV_WORK* wk )
{
	int i;
	WORDSET* wset = MUSEUM_BMPWIN_GetWordset( wk->wk_msg );

	WORDSET_RegisterPkthlnMatch( wset, 0, wk->ev_idx );

	MUSEUM_BMPWIN_PrintAndSetOfs( wk->wk_msg, BMPWIN_ID_EVNAME,	msg_pkthRNK_evname, 1, 1 );
	MUSEUM_BMPWIN_PrintEx( wk->wk_msg, BMPWIN_ID_S_EVNAME_R,	msg_pkthRNK_evnameR_01 + wk->ev_idx, FALSE, 1, FONT_SYSTEM );

	// 参加回数を表示
	{
		WORDSET* wset = MUSEUM_BMPWIN_GetWordset( wk->wk_msg );

		WORDSET_RegisterNumber( wset, 0, CONST_DATA_GetJoinCount(  wk->wk_con, wk->ev_idx, wk->b_comm ),
				7, NUMBER_DISPTYPE_SPACE, NUMBER_CODETYPE_DEFAULT );

		MUSEUM_BMPWIN_PrintAndSetOfs( wk->wk_msg, BMPWIN_ID_JOIN, msg_pkthRNK_evjoin, 1, 0 );
	}

	// レコード表示
	for( i=0; i<BEST_FIVE; i++ )
	{
		if( check_data_none( wk, i ) == FALSE )
		{
			// レコード表示
			u16 scr = CONST_DATA_GetEventRecord( wk->wk_con, wk->ev_idx, i, wk->b_comm );
			PRINT_Record( wk, scr, BMPWIN_ID_S_TIME01 + i, msg_pkthRNK_evunit_01 + wk->ev_idx );
		}
		else
		{
			// データがないとき → --- てん
			MUSEUM_BMPWIN_PrintEx( wk->wk_msg, BMPWIN_ID_S_TIME01 + i, msg_pkthRNK_evunit_n01 + wk->ev_idx, FALSE, 1, FONT_SYSTEM );
		}
	}

	//===========================================================
	// モードによる表示の切替
	//===========================================================
	//-- つうしん
	if( wk->b_comm )
	{
		MUSEUM_BMPWIN_Print( wk->wk_msg, BMPWIN_ID_S_EVTRP, msg_pkthRNK_evtrophy_t, FALSE );	// つうしんモード

		// 通信トレーナー名を一端非表示
		BMPWIN_ClearCommTrainerName( wk );

		for( i=0; i<BEST_FIVE; i++ )
		{
			// データがなければ飛ばす
			if( check_data_none( wk, i ) ){ continue; }

			// トレーナー名
			MUSEUM_BMPWIN_PrintStrbuf( wk->wk_msg, BMPWIN_ID_S_COMMTR01 + i, CONST_DATA_GetCommTrainerName( wk->wk_con, wk->ev_idx, i ), 0, 1 );
		}

	}
	else
	//-- 通常
	{
		// ポイント表記
		if( wk->b_1st_dummy[ wk->ev_idx ] )
		{
			// ポイントをクリア
			MUSEUM_BMPWIN_ClearAndTransReq( wk->wk_msg, BMPWIN_ID_S_POINT );
			MUSEUM_BMPWIN_ClearAndTransReq( wk->wk_msg, BMPWIN_ID_S_POINT_CAP );
		}
		else
		{
			// ポイントを表示
			MUSEUM_BMPWIN_PrintNum( wk->wk_msg, BMPWIN_ID_S_POINT, msg_pkthRNK_point, CONST_DATA_GetEventPoint( wk->wk_con, wk->ev_idx ), 3, 0 );
			MUSEUM_BMPWIN_Print( wk->wk_msg, BMPWIN_ID_S_POINT_CAP, msg_pkthRNK_point_cap, FALSE );
		}

		// ボタンを指していれば表示を消す
		if( wk->ev_idx < 0 )
		{
			MUSEUM_BMPWIN_ClearAndTransReq( wk->wk_msg, BMPWIN_ID_S_EVTRP );
		}

		// 上画面の2行目
		if( CONST_DATA_GetMuseumOpenFlag( wk->wk_con ) == FALSE )
		{
			if( wk->b_1st_dummy[ wk->ev_idx ] )
			{
				// ダミートレーナー名
				MUSEUM_BMPWIN_Print( wk->wk_msg, BMPWIN_ID_S_EVTRP, msg_pkthRNK_ev1st_dummy, FALSE );
			}
			else
			{
				// トレーナー名
				MUSEUM_BMPWIN_PrintPlayerName( wk->wk_msg, BMPWIN_ID_S_EVTRP, msg_pkthRNK_ev1st, 0, CONST_DATA_GetMyStatus( wk->wk_con ) );
			}
		}
		else
		{
			if( check_record_flag( wk, wk->ev_idx ) )
			{
				// トレーナー名
				MUSEUM_BMPWIN_PrintPlayerName( wk->wk_msg, BMPWIN_ID_S_EVTRP, msg_pkthRNK_ev1st, 0, CONST_DATA_GetMyStatus( wk->wk_con ) );
			}
			else
			{
				// クリア条件
				MUSEUM_BMPWIN_Print( wk->wk_msg, BMPWIN_ID_S_EVTRP, msg_pkthRNK_evtrophy_01 + wk->ev_idx, FALSE );
			}
		}

	}
}

//-----------------------------------------------------------------------------
/**
 *	@brief	OBJ 初期化処理
 *
 *	@param	MUSEUM_EV_WORK* wk
 *
 *	@retval
 */
//-----------------------------------------------------------------------------
static void OBJ_Init( MUSEUM_EV_WORK* wk )
{
	TCATS_RESOURCE_NUM_LIST crnl = { CHR_ID_MAX, PAL_ID_MAX, CEL_ID_MAX, ANM_ID_MAX, 0 };
	wk->wk_obj = MUSEUM_OBJ_Create( wk->heapID, &crnl, OBJ_ID_MAX );

	OBJ_LoadRes( wk );

	//-- CAP初期化
	OBJ_AddCommon( wk );
	OBJ_AddEvIconOption( wk );
	OBJ_AddPokeIcon( wk );

	//-- 表示
	OBJ_Flash( wk );
}

//-----------------------------------------------------------------------------
/**
 *	@brief	OBJ 更新処理
 *
 *	@param	MUSEUM_EV_WORK* wk
 *
 *	@retval
 */
//-----------------------------------------------------------------------------
static void OBJ_Flash( MUSEUM_EV_WORK* wk )
{
	BOOL b_clear = (wk->b_comm) ? FALSE : !wk->b_1st_dummy[wk->ev_idx];
	OBJ_PokeIconFlash( wk );
	CATS_ObjectEnableCap( wk->cap[ OBJ_ID_S_1ST ], b_clear );
}

//-----------------------------------------------------------------------------
/**
 *	@brief	OBJ リソースロード
 *
 *	@param	MUSEUM_EV_WORK* wk
 *
 *	@retval
 */
//-----------------------------------------------------------------------------
static void OBJ_LoadRes( MUSEUM_EV_WORK* wk )
{
	CATS_SYS_PTR	csp = MUSEUM_OBJ_GetCsp( wk->wk_obj );
	CATS_RES_PTR	crp = MUSEUM_OBJ_GetCrp( wk->wk_obj );

	// -- obj_trophy --
	CATS_LoadResourceCharArcH( csp, crp, wk->p_arc_pkth_museum,
			NARC_pkth_museum_obj_trophy_lz_NCGR, TRUE, NNS_G2D_VRAM_TYPE_2DMAIN, CHR_ID_M_TROPHY );

	CATS_LoadResourcePlttArcH( csp, crp, wk->p_arc_pkth_museum,
			NARC_pkth_museum_obj_trophy_NCLR, 0, 1, NNS_G2D_VRAM_TYPE_2DMAIN, PAL_ID_M_TROPHY );

	CATS_LoadResourceCellArcH( csp, crp, wk->p_arc_pkth_museum,
			NARC_pkth_museum_obj_trophy_lz_NCER, TRUE, CEL_ID_TROPHY );

	CATS_LoadResourceCellAnmArcH( csp, crp,  wk->p_arc_pkth_museum,
			NARC_pkth_museum_obj_trophy_lz_NANR, TRUE, ANM_ID_TROPHY );

	// -- event_obj_sub --
	CATS_LoadResourcePlttArcH( csp, crp, wk->p_arc_pkth_museum,
			NARC_pkth_museum_event_obj_NCLR, 0, 1, NNS_G2D_VRAM_TYPE_2DSUB, PAL_ID_S_EVENT );

	CATS_LoadResourceCharArcH( csp, crp, wk->p_arc_pkth_museum,
			NARC_pkth_museum_event_obj_sub_lz_NCGR, TRUE, NNS_G2D_VRAM_TYPE_2DSUB, CHR_ID_S_EVENT );

	CATS_LoadResourceCellArcH( csp, crp, wk->p_arc_pkth_museum,
			NARC_pkth_museum_event_obj_sub_lz_NCER, TRUE, CEL_ID_S_EVENT );

	CATS_LoadResourceCellAnmArcH( csp, crp,  wk->p_arc_pkth_museum,
			NARC_pkth_museum_event_obj_sub_lz_NANR, TRUE, ANM_ID_S_EVENT );

	// -- pokeicon用リソース
	{
		static const MUSEUM_OBJ_ID c_pkicon_id = {
			CHR_ID_S_POKEICON_HEAD, PAL_ID_S_POKEICON, CEL_ID_POKEICON, ANM_ID_POKEICON,
		};
		MUSEUM_OBJ_POKEICON_LoadRes( wk->wk_obj, &c_pkicon_id, OBJ_POKEICON_MAX, FALSE, TRUE );
	}

}

//-----------------------------------------------------------------------------
/**
 *	@brief	汎用セルアクター追加
 *
 *	@param	MUSEUM_EV_WORK * wk
 *
 *	@retval
 */
//-----------------------------------------------------------------------------
static void OBJ_AddCommon( MUSEUM_EV_WORK * wk )
{
	static const TCATS_OBJECT_ADD_PARAM_S	common_prm[ OBJ_ID_COMMON_MAX ] =
	{
		{	// OBJ_ID_CURSOR
			OBJPOS_CUR_DEF_X, OBJPOS_CUR_DEF_Y,	0,
			NANR_obj_trophy_cur_ev, 0, 0, NNS_G2D_VRAM_TYPE_2DMAIN,
			{ CHR_ID_M_TROPHY, PAL_ID_M_TROPHY, CEL_ID_TROPHY, ANM_ID_TROPHY, 0, 0 }, 0, FALSE,
		},
		{	// OBJ_ID_S_1ST
			OBJPOS_S_1ST_X,	OBJPOS_S_1ST_Y,	0,
			0, 0, 0, NNS_G2D_VRAM_TYPE_2DSUB,
			{ CHR_ID_S_EVENT, PAL_ID_S_EVENT, CEL_ID_S_EVENT, ANM_ID_S_EVENT, 0, 0 }, 0, FALSE,
		},
	};

	int i;

	// COMMON OBJ初期化
	for( i=0; i < OBJ_ID_COMMON_MAX; i++ )
	{
		wk->cap[ i ] = MUSEUM_OBJ_Add( wk->wk_obj, &common_prm[ i ] );
		CATS_ObjectAutoAnimeSetCap( wk->cap[ i ], TRUE );
	}
}

//-----------------------------------------------------------------------------
/**
 *	@brief	イベントアイコンに付随するOBJを追加
 *
 *	@param	MUSEUM_EV_WORK* wk
 *
 *	@retval
 */
//-----------------------------------------------------------------------------
static void OBJ_AddEvIconOption( MUSEUM_EV_WORK* wk )
{

	TCATS_OBJECT_ADD_PARAM_S prm = {0};
	u32 i, j;

	static const int res_tbl[] = { CHR_ID_M_TROPHY, PAL_ID_M_TROPHY, CEL_ID_TROPHY, ANM_ID_TROPHY, 0, 0 };

	for( i=0; i < BG_EVICON_LINE; i++ )
	{
		for( j=0; j < BG_EVICON_ROW; j++ )
		{
			u8 cnt = ( i * BG_EVICON_ROW + j );

			// 共通パラメータ
			MI_CpuCopy8( res_tbl, prm.id, sizeof(prm.id) );
			prm.d_area = NNS_G2D_VRAM_TYPE_2DMAIN;
			prm.x = OBJPOS_CUR_DEF_X + j * OBJPOS_CUR_DIFF_X;
			prm.y = OBJPOS_CUR_DEF_Y + i * OBJPOS_CUR_DIFF_Y;

			//-- リボン生成
			{
				int rbn_idx = OBJ_ID_EVICON_RIBBON_HEAD + cnt;

				prm.pri = 0;
				prm.anm = NANR_obj_trophy_ribbon_ev;
				wk->cap[ rbn_idx ] = MUSEUM_OBJ_Add( wk->wk_obj, &prm );

				CATS_ObjectEnableCap( wk->cap[ rbn_idx ], !wk->b_1st_dummy[cnt] );
			}

			//-- トロフィー生成
			{
				int trp_idx = OBJ_ID_EVICON_TROPHY_HEAD + cnt;
				prm.pri = 1;
				prm.anm = NANR_obj_trophy_trp_single_ev;
				wk->cap[ trp_idx ] = MUSEUM_OBJ_Add( wk->wk_obj, &prm );

				CATS_ObjectEnableCap( wk->cap[ trp_idx ], check_trophy_flag( wk, cnt, TRUE ) );
				CATS_ObjectAutoAnimeSetCap( wk->cap[ trp_idx ], TRUE );
			}

			// BGをロード
			{
				u16 pos_x, pos_y;

				pos_x = BG_EVICON_DEF_X + j * BG_EVICON_DIFF_X;
				pos_y = BG_EVICON_DEF_Y + i * BG_EVICON_DIFF_Y;
				BG_LoadEvIcon( wk, cnt, pos_x, pos_y, !wk->b_1st_dummy[cnt], FALSE );
			}
		}
	}
}


//-----------------------------------------------------------------------------
/**
 *	@brief	ポケモンアイコン 追加
 *
 *	@param	MUSEUM_EV_WORK* wk
 *
 *	@retval
 */
//-----------------------------------------------------------------------------
static void OBJ_AddPokeIcon( MUSEUM_EV_WORK* wk )
{
	TCATS_OBJECT_ADD_PARAM_S prm = {0};
	u32 i, j;
	const s16 def_x = 7*8+4;
	const s16 def_y = 5*8+4;

	for( i=0; i < OBJ_POKEICON_LINE; i++ )
	{
		for( j=0; j < OBJ_POKEICON_ROW; j++ )
		{
			int cap_idx = OBJ_ID_S_POKEICON_HEAD + ( i * OBJ_POKEICON_ROW + j );

			prm.id[ 0 ] = CHR_ID_S_POKEICON_HEAD + ( i * OBJ_POKEICON_ROW + j );
			prm.id[ 1 ] = PAL_ID_S_POKEICON;
			prm.id[ 2 ] = CEL_ID_POKEICON;
			prm.id[ 3 ] = ANM_ID_POKEICON;
			prm.d_area = NNS_G2D_VRAM_TYPE_2DSUB;
			prm.x = def_x + j * 24 + i * 8;
			prm.y = def_y + i * 32;
			prm.pri = OBJ_POKEICON_ROW - j;

			wk->cap[ cap_idx ] = MUSEUM_OBJ_Add( wk->wk_obj, &prm );
			CATS_ObjectAutoAnimeSetCap( wk->cap[ cap_idx ], TRUE );
		}
	}
}

//-----------------------------------------------------------------------------
/**
 *	@brief	ポケモンアイコンを更新
 *
 *	@param	MUSEUM_EV_WORK* wk
 *
 *	@retval
 */
//-----------------------------------------------------------------------------
static void OBJ_PokeIconFlash( MUSEUM_EV_WORK* wk )
{
	int i, r;

	for(i=0; i<OBJ_POKEICON_LINE; i++ )
	{
		int rec = CONST_DATA_GetEventRecord( wk->wk_con, wk->ev_idx, i, wk->b_comm );

		if( rec == REC_NO_DATA ){ continue; }

		for(r=0; r<OBJ_POKEICON_ROW; r++ )
		{
			MONS_DATA mons = {0};
			int cap_idx = OBJ_ID_S_POKEICON_HEAD + ( i * OBJ_POKEICON_ROW + r );

			CONST_DATA_GetMonsDataPtr( wk->wk_con, &mons, wk->ev_idx, i, r, wk->b_comm );

			if( mons.MonsNo != 0 )
			{
				MUSEUM_OBJ_POKEICON_Draw( wk->wk_obj, wk->cap[ cap_idx ], &mons, FALSE, TRUE );

				CATS_ObjectEnableCap( wk->cap[ cap_idx ], CATS_ENABLE_TRUE );
				//-- TOPのアニメは2倍速
				if( i == 0 )
				{
					CATS_ObjectAutoAnimeSpeedSetCap( wk->cap[ cap_idx ], FX32_CONST(1.5) );
				}
			}
		}
	}
}

//-----------------------------------------------------------------------------
/**
 *	@brief	ポケモンアイコンを全て非表示
 *
 *	@param	MUSEUM_EV_WORK* wk
 *
 *	@retval
 */
//-----------------------------------------------------------------------------
static void OBJ_PokeIconEnable( MUSEUM_EV_WORK* wk, BOOL b_enable )
{
	int i, r;
	for(i=0; i<OBJ_POKEICON_LINE; i++ )
	{
		for(r=0; r<OBJ_POKEICON_ROW; r++ )
		{
			int cap_idx = OBJ_ID_S_POKEICON_HEAD + ( i * OBJ_POKEICON_ROW + r );
			CATS_ObjectEnableCap( wk->cap[ cap_idx ], b_enable );
		}
	}
}

//-----------------------------------------------------------------------------
/**
 *	@brief	通信トレーナー名を消す
 *
 *	@param	MUSEUM_EV_WORK* wk
 *
 *	@retval
 */
//-----------------------------------------------------------------------------
static void BMPWIN_ClearCommTrainerName( MUSEUM_EV_WORK* wk )
{
	int i;

	for( i=0; i<BEST_FIVE; i++ )
	{
		MUSEUM_BMPWIN_ClearAndTransReq( wk->wk_msg, BMPWIN_ID_S_COMMTR01 + i );
	}
}

//-----------------------------------------------------------------------------
/**
 *	@brief	BGアイコンとオプションを更新
 *
 *	@param	MUSEUM_EV_WORK* wk
 *
 *	@retval
 */
//-----------------------------------------------------------------------------
static void EVICON_Flash( MUSEUM_EV_WORK* wk )
{
	u32 i, j;

	for( i=0; i < BG_EVICON_LINE; i++ )
	{
		for( j=0; j < BG_EVICON_ROW; j++ )
		{
			u8 cnt = ( i * BG_EVICON_ROW + j );
			BOOL b_clear;

			// 通信データ表示時は必ず表示
			b_clear = (wk->b_comm) ? TRUE : !wk->b_1st_dummy[cnt];

			//-- リボン判定
			{
				int rbn_idx = OBJ_ID_EVICON_RIBBON_HEAD + cnt;
				BOOL b_ribbon = (wk->b_comm) ? FALSE : b_clear;
				CATS_ObjectEnableCap( wk->cap[ rbn_idx ], b_ribbon );
			}

			//-- トロフィー
			{
				int trp_idx = OBJ_ID_EVICON_TROPHY_HEAD + cnt;
				CATS_ObjectEnableCap( wk->cap[ trp_idx ], check_trophy_flag( wk, cnt, TRUE ) );
			}

			//-- BGをロード
			{
				u16 pos_x, pos_y;

				pos_x = BG_EVICON_DEF_X + j * BG_EVICON_DIFF_X;
				pos_y = BG_EVICON_DEF_Y + i * BG_EVICON_DIFF_Y;


				BG_LoadEvIcon( wk, cnt, pos_x, pos_y, b_clear, FALSE );
			}
		}
	}
}

//-----------------------------------------------------------------------------
/**
 *	@brief	カーソル処理
 *
 *	@param	MUSEUM_EV_WORK* wk
 *
 *	@retval	TRUE : 終了
 */
//-----------------------------------------------------------------------------
static BOOL CURSOR_Proc( MUSEUM_EV_WORK* wk )
{
	enum {
		EVICON_SIZE		= 8*6,	EVICON_DIFF_Y	= 8*8,
		EVICON_DEF_T	= 8*6,	EVICON_DEF_B	= 8*12,	EVICON_DEF_L	= 8*1,	EVICON_DEF_R	= 8*7,
		CHGBTL_DEF_T	= 0,	CHGBTL_DEF_B	= 8*4,	CHGBTL_DEF_L	= 8*24,	CHGBTL_DEF_R	= 8*32,
		CHGBTL_OBJ_X	= CHGBTL_DEF_L + 8*4,
		CHGBTL_OBJ_Y	= CHGBTL_DEF_T + 8*2,
	};

	s8 pre_idx;
	BOOL ret = FALSE;

	pre_idx = wk->ev_idx;

	// ----- 入力処理 -----
	// -- タッチ操作
	if( sys.tp_trg )
	{
		static const RECT_HIT_TBL rect_data[] = {
			{ CHGBTL_DEF_T,					CHGBTL_DEF_B,					CHGBTL_DEF_L,					CHGBTL_DEF_R },
			{ EVICON_DEF_T,					EVICON_DEF_B,					EVICON_DEF_L,					EVICON_DEF_R },
			{ EVICON_DEF_T,					EVICON_DEF_B,					EVICON_DEF_L + EVICON_SIZE,		EVICON_DEF_R + EVICON_SIZE },
			{ EVICON_DEF_T,					EVICON_DEF_B,					EVICON_DEF_L + EVICON_SIZE*2,	EVICON_DEF_R + EVICON_SIZE*2 },
			{ EVICON_DEF_T,					EVICON_DEF_B,					EVICON_DEF_L + EVICON_SIZE*3,	EVICON_DEF_R + EVICON_SIZE*3 },
			{ EVICON_DEF_T,					EVICON_DEF_B,					EVICON_DEF_L + EVICON_SIZE*2,	EVICON_DEF_R + EVICON_SIZE*4 },
			{ EVICON_DEF_T + EVICON_DIFF_Y,	EVICON_DEF_B + EVICON_DIFF_Y,	EVICON_DEF_L,					EVICON_DEF_R },
			{ EVICON_DEF_T + EVICON_DIFF_Y,	EVICON_DEF_B + EVICON_DIFF_Y,	EVICON_DEF_L + EVICON_SIZE,		EVICON_DEF_R + EVICON_SIZE },
			{ EVICON_DEF_T + EVICON_DIFF_Y,	EVICON_DEF_B + EVICON_DIFF_Y,	EVICON_DEF_L + EVICON_SIZE*2,	EVICON_DEF_R + EVICON_SIZE*2 },
			{ EVICON_DEF_T + EVICON_DIFF_Y,	EVICON_DEF_B + EVICON_DIFF_Y,	EVICON_DEF_L + EVICON_SIZE*3,	EVICON_DEF_R + EVICON_SIZE*3 },
			{ EVICON_DEF_T + EVICON_DIFF_Y,	EVICON_DEF_B + EVICON_DIFF_Y,	EVICON_DEF_L + EVICON_SIZE*4,	EVICON_DEF_R + EVICON_SIZE*4 },
			{ TP_HIT_END, 0, 0, 0 },
		};

		int result;

		result = GF_TP_HitTrg( rect_data );
		if( result != RECT_HIT_NONE )
		{
			// カーソル移動
//			if( result - 1 != wk->ev_idx )
			{
				wk->ev_idx = result - 1;
				CATS_ObjectAnimeSeqSetCap( wk->cap[ OBJ_ID_CURSOR ], NANR_obj_trophy_cur_ev_tp );
				// 移動音
				Snd_SePlay( SEQ_SE_DP_SELECT );
			}

			//-- モード切替
			if( wk->ev_idx == BTN_IDX_CHG )
			{
				wk->b_comm_flash = TRUE;
				CATS_ObjectAnimeSeqSetCap( wk->cap[ OBJ_ID_CURSOR ], NANR_obj_trophy_cur_btn_tp );
				Snd_SePlay( SEQ_SE_DP_SELECT );
			}

			CATS_ObjectAutoAnimeSetCap( wk->cap[ OBJ_ID_CURSOR ], TRUE );
		}
	}
	// -- キー入力
	else
	{
		if( (sys.trg & PAD_BUTTON_A) )
		{
			//-- もどる
			if( wk->ev_idx == PKTHLN_EVT_MAX ){ return TRUE; } else
			//-- モード切替
			if( wk->ev_idx == BTN_IDX_CHG ){ wk->b_comm_flash = TRUE; Snd_SePlay( SEQ_SE_DP_SELECT ); }
		}

		// -- カーソル移動
		// チェンジボタン
		if( wk->ev_idx == BTN_IDX_CHG )
		{
			if( sys.repeat_org & PAD_KEY_DOWN ){ wk->ev_idx = wk->cur_row_old; }
		}
		// リターンボタン
		else if( wk->ev_idx == BTN_IDX_RETURN )
		{
			if( sys.repeat_org & PAD_KEY_UP	){ wk->ev_idx = wk->cur_row_old + BG_EVICON_ROW; }
		}
		else
		// 特殊ボタン以外
		{
			if( sys.repeat_org & PAD_KEY_RIGHT	){ wk->ev_idx += 1; } else
			if( sys.repeat_org & PAD_KEY_LEFT	){ wk->ev_idx -= 1; } else
			if( sys.repeat_org & PAD_KEY_DOWN	){ wk->ev_idx += BG_EVICON_ROW; } else
			if( sys.repeat_org & PAD_KEY_UP		){ wk->ev_idx -= ( wk->ev_idx == PKTHLN_EVT_MAX ) ? 1 : BG_EVICON_ROW; }

			// 回りこみ対策
			wk->ev_idx = MATH_CLAMP( wk->ev_idx, BTN_IDX_CHG, PKTHLN_EVT_MAX );

			// 移動先が特殊ボタン以外ならROW座標を保存
			if( wk->ev_idx != BTN_IDX_CHG && wk->ev_idx != BTN_IDX_RETURN )
			{
				wk->cur_row_old = wk->ev_idx % BG_EVICON_ROW;
			}
		}
	}

	// ----- 値が変更された ----
	if( pre_idx	!= wk->ev_idx )
	{
		// 移動音
		Snd_SePlay( SEQ_SE_DP_SELECT );

		// カーソル移動
		{
			//--つうしん/シングル 切替ボタン
			if( wk->ev_idx == BTN_IDX_CHG )
			{
				CATS_ObjectPosSetCap( wk->cap[ OBJ_ID_CURSOR ],	CHGBTL_OBJ_X, CHGBTL_OBJ_Y );
				CATS_ObjectAnimeSeqSetCap( wk->cap[ OBJ_ID_CURSOR ], NANR_obj_trophy_cur_btn );
			}
			else if( wk->ev_idx == PKTHLN_EVT_MAX )
			//--もどる ボタン
			{
				enum { POS_EXIT_X = 28*8,	POS_EXIT_Y = 22*8, };
				CATS_ObjectPosSetCap( wk->cap[ OBJ_ID_CURSOR ],	POS_EXIT_X, POS_EXIT_Y );
				CATS_ObjectAnimeSeqSetCap( wk->cap[ OBJ_ID_CURSOR ], NANR_obj_trophy_cur_btn );
			}
			//-- リスト本体
			else
			{
				u32 seq;
				s16 pos_x, pos_y;
				s8 idx = wk->ev_idx;
				BOOL b_under = ( wk->ev_idx >= (PKTHLN_EVT_MAX>>1) );

				if( b_under ){ idx -= (PKTHLN_EVT_MAX>>1); }
				pos_x = OBJPOS_CUR_DEF_X + idx * OBJPOS_CUR_DIFF_X;
				pos_y = OBJPOS_CUR_DEF_Y + b_under * OBJPOS_CUR_DIFF_Y;
				CATS_ObjectPosSetCap( wk->cap[ OBJ_ID_CURSOR ],	pos_x, pos_y );

				// タッチされていなければ直ちにカーソルを基本形に
				seq = CATS_ObjectAnimeSeqGetCap( wk->cap[ OBJ_ID_CURSOR ] );
				if( seq != NANR_obj_trophy_cur_ev_tp )
				{
					CATS_ObjectAnimeSeqSetCap( wk->cap[ OBJ_ID_CURSOR ], NANR_obj_trophy_cur_ev );
				}

				// EXIT → 一個前の要素 の時は項目の内容が一緒なので更新しない
				if( !(pre_idx == PKTHLN_EVT_MAX && wk->ev_idx == PKTHLN_EVT_MAX-1) )
				{
					OBJ_PokeIconEnable( wk, FALSE );	// 切り替えた瞬間は全てのポケアイコンを消す
					wk->b_gph_flash = TRUE;	// OBJ更新フラグON
				}
			}
		}
	}

	return ret;
}

//-----------------------------------------------------------------------------
/**
 *	@brief	一位のデータをダミーにする
 *
 *	@param	MUSEUM_EV_WORK* wk
 *	@param	PKTH_EVT_DATA* p_src
 *	@param	p_dst
 *
 *	@retval
 */
//-----------------------------------------------------------------------------
static void set_dummy_data( MUSEUM_EV_WORK* wk, const PKTH_EVT_DATA* p_src, PKTH_EVT_DATA* p_dst )
{
	int i, j;

	// データをコピーしておく
	MI_CpuCopy8( p_src, p_dst, sizeof( PKTH_EVT_DATA ) * PKTHLN_EVT_MAX );

	HOSAKA_PRINT( "--- Create Dummy Data ---\n");

	// ダミーデータを入れる位置を探索
	for( i=0; i<PKTHLN_EVT_MAX; i++ )
	{
		for( j=0; j<BEST_FIVE; j++ )
		{
			if( MUSEUM_UTIL_CheckEventRecordFlag( i, FALSE, p_src[i].RcMs[j].Record ) == FALSE )
			{
				break;
			}
		}

		HOSAKA_PRINT( "ev_idx=%d rnk_idx=%d \n",i,j);

		// 一位のデータがダミーを越せなければ、フラグをたてる
		if( j==0 )
		{
			wk->b_1st_dummy[i] = TRUE;
		}

		// ソート
		{
			int k;
			for( k=0; k<BEST_FIVE; k++ )
			{
				// ダミーデータを入れる
				if( k == j )
				{
					u16 dmy[3] = { MONSNO_TIKORIITA, MONSNO_HINOARASI, MONSNO_WANINOKO };	///< 最初の三匹
					MI_CpuCopy8( dmy, p_dst[i].RcMs[k].FrmMnsNo, sizeof(u16)*3 );
					p_dst[i].RcMs[k].Record = MUSEUM_UTIL_GetEventDefaultRecord( i, FALSE );
				}
				else if( k > j )
				{
					p_dst[i].RcMs[k] = p_src[i].RcMs[k-1];
				}
			}
		}
	}
}

//-----------------------------------------------------------------------------
/**
 *	@brief	参照用データ 生成
 *
 *	@param	MUSEUM_EV_WORK*wk
 *	@param	p_param
 *
 *	@retval
 */
//-----------------------------------------------------------------------------
static void CONST_DATA_Create( MUSEUM_EV_WORK*wk, PKTH_MUSEUM_EV_PARAM* p_param )
{
	int i;
	CONST_DATA* cwk = NULL;

	cwk = sys_AllocMemory( wk->heapID, sizeof(CONST_DATA) );
	MI_CpuClear8( cwk, sizeof(CONST_DATA) );

	cwk->p_param = p_param;

	set_dummy_data( wk, cwk->p_param->p_ev_alone, cwk->ev_alone );


	cwk->trname = STRBUF_Create( PERSON_NAME_SIZE + EOM_SIZE , wk->heapID );

	wk->wk_con = cwk;
}

//-----------------------------------------------------------------------------
/**
 *	@brief	参照用データ 開放
 *
 *	@param	const CONST_DATA* wk
 *
 *	@retval
 */
//-----------------------------------------------------------------------------
static void CONST_DATA_Release( const CONST_DATA* wk )
{
	STRBUF_Delete( wk->trname );
	sys_FreeMemoryEz( (CONST_DATA*)wk );
}

//-----------------------------------------------------------------------------
static const PKTH_EVT_DATA* get_evt_data( const CONST_DATA* wk, u8 ev_idx, BOOL b_comm )
{
	const PKTH_EVT_DATA* p_evdat;

	GF_ASSERT_MSG( ev_idx < PKTHLN_EVT_MAX, "ev_idx:%d\n",	ev_idx );

	if( b_comm )
	{
		p_evdat = &wk->p_param->p_ev_comm[ ev_idx ].EvtData;
	}
	else
	{
		p_evdat = &wk->ev_alone[ ev_idx ];
	}

	return p_evdat;
}

//-----------------------------------------------------------------------------
/**
 *	@brief	ミュージアムフラグを取得
 *
 *	@param	const CONST_DATA* wk
 *
 *	@retval
 */
//-----------------------------------------------------------------------------
static BOOL CONST_DATA_GetMuseumOpenFlag( const CONST_DATA* wk )
{
	return wk->p_param->b_museum_open;
}

//-----------------------------------------------------------------------------
/**
 *	@brief	指定ランクのモンスターデータを取得
 *
 *	@param	const CONST_DATA* wk
 *	@param	ev_idx
 *	@param	rank_idx
 *
 *	@retval
 */
//-----------------------------------------------------------------------------
static void CONST_DATA_GetMonsDataPtr( const CONST_DATA* wk, MONS_DATA* p_dst, int ev_idx, int rank_idx, int pk_idx, BOOL b_comm )
{
	const PKTH_EVT_DATA* p_evdat;
	u16 dat;

	GF_ASSERT( wk );
	GF_ASSERT_MSG( rank_idx < BEST_FIVE,	"rank_idx:%d\n",	rank_idx );
	GF_ASSERT_MSG( pk_idx < POKE_ENTRY_MAX, "pk_idx:%d\n",		pk_idx );

	p_evdat = get_evt_data( wk, ev_idx, b_comm );

	dat = p_evdat->RcMs[ rank_idx ].FrmMnsNo[ pk_idx ];

	p_dst->MonsNo = ( dat & 0x3FF );
	p_dst->Form = ( dat >> 10 );
}

//-----------------------------------------------------------------------------
/**
 *	@brief	ランクスコアを取得
 *
 *	@param	const CONST_DATA* wk
 *	@param	ev_idx
 *	@param
 *
 *	@retval
 */
//-----------------------------------------------------------------------------
static u16 CONST_DATA_GetEventRecord( const CONST_DATA* wk, s8 ev_idx, u8 rnk_idx, BOOL b_comm )
{
	const PKTH_EVT_DATA* p_evdat;

	GF_ASSERT( wk );
	GF_ASSERT_MSG( rnk_idx < BEST_FIVE,	"rnk_idx:%d\n",	rnk_idx );

	p_evdat = get_evt_data( wk, ev_idx, b_comm );
	return MUSEUM_UTIL_GetEventRecord( p_evdat, rnk_idx );
}

//-----------------------------------------------------------------------------
/**
 *	@brief	参加回数を取得
 *
 *	@param	const CONST_DATA* wk
 *	@param	ev_idx
 *	@param	b_comm
 *
 *	@retval	参加回数
 */
//-----------------------------------------------------------------------------
static u32 CONST_DATA_GetJoinCount( const CONST_DATA* wk, u8 ev_idx, BOOL b_comm )
{
	const PKTH_EVT_DATA* p_evdat;

	p_evdat = get_evt_data( wk, ev_idx, b_comm );
	return p_evdat->EntryNum;
}

//-----------------------------------------------------------------------------
/**
 *	@brief	プレイヤーのステータスを取得
 *
 *	@param	const CONST_DATA* wk
 *
 *	@retval	プレイヤーのステータス
 */
//-----------------------------------------------------------------------------
static const MYSTATUS* CONST_DATA_GetMyStatus( const CONST_DATA* wk )
{
	GF_ASSERT( wk );

	return wk->p_param->p_st;
}

//-----------------------------------------------------------------------------
/**
 *	@brief	通信時のトレーナー名を取得
 *
 *	@param	const CONST_DATA* wk
 *	@param	ev_idx
 *	@param	rnk_idx
 *
 *	@retval
 */
//-----------------------------------------------------------------------------
static STRBUF* CONST_DATA_GetCommTrainerName( const CONST_DATA* wk, u8 ev_idx, u8 rnk_idx )
{
	GF_ASSERT( wk );

	STRBUF_SetStringCode( wk->trname, (const STRCODE*)wk->p_param->p_ev_comm[ ev_idx ].TrData[ rnk_idx ].TrName );

	return wk->trname;
}